package com.example.litepal;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

public class list_Apadter extends BaseAdapter {
    private List<Info> list;
    private Context context;

    public list_Apadter(List<Info> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder=null;
        if (view==null)
        {
            holder=new ViewHolder();
            view= LayoutInflater.from(context).inflate(R.layout.list_mode,viewGroup,false);
            holder.title=view.findViewById(R.id.title);
            holder.time_t=view.findViewById(R.id.time_t);
            view.setTag(holder);
        }else
        {
            holder = (ViewHolder) view.getTag();
        }
        holder.title.setText(list.get(i).getContent());
        holder.time_t.setText(list.get(i).getDate());
        return view;
    }
    class ViewHolder{
        TextView title;
        TextView time_t;
    }
}
